Home | History | Annotate | Line # | Download | only in ic
dp83932var.h revision 1.10
      1  1.10  tsutsui /*	$NetBSD: dp83932var.h,v 1.10 2008/04/23 13:29:45 tsutsui Exp $	*/
      2   1.1  thorpej 
      3   1.1  thorpej /*-
      4   1.1  thorpej  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5   1.1  thorpej  * All rights reserved.
      6   1.1  thorpej  *
      7   1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1  thorpej  * by Jason R. Thorpe.
      9   1.1  thorpej  *
     10   1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     11   1.1  thorpej  * modification, are permitted provided that the following conditions
     12   1.1  thorpej  * are met:
     13   1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     14   1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     15   1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     17   1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     18   1.1  thorpej  * 3. All advertising materials mentioning features or use of this software
     19   1.1  thorpej  *    must display the following acknowledgement:
     20   1.1  thorpej  *	This product includes software developed by the NetBSD
     21   1.1  thorpej  *	Foundation, Inc. and its contributors.
     22   1.1  thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23   1.1  thorpej  *    contributors may be used to endorse or promote products derived
     24   1.1  thorpej  *    from this software without specific prior written permission.
     25   1.1  thorpej  *
     26   1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27   1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28   1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29   1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30   1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31   1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32   1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33   1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34   1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35   1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36   1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     37   1.1  thorpej  */
     38   1.1  thorpej 
     39   1.1  thorpej #ifndef _DEV_IC_DP83932VAR_H_
     40   1.1  thorpej #define	_DEV_IC_DP83932VAR_H_
     41   1.1  thorpej 
     42   1.1  thorpej /*
     43   1.1  thorpej  * Data structure definitions for the National Semiconductor DP83932
     44   1.1  thorpej  * Systems-Oriented Network Interface Controller (SONIC).
     45   1.1  thorpej  */
     46   1.1  thorpej 
     47   1.1  thorpej /*
     48   1.1  thorpej  * NOTE: The control data for the SONIC must not cross a 64k boundary,
     49   1.1  thorpej  * so we have to be careful about how we size things.
     50   1.1  thorpej  *
     51   1.1  thorpej  * Also, since the SONIC is only a 10Mb/s chip, and systems on which
     52   1.1  thorpej  * it is present tend to be low on memory, we try to keep the data
     53   1.1  thorpej  * structure sizes small.
     54   1.1  thorpej  */
     55   1.1  thorpej 
     56   1.1  thorpej /*
     57   1.1  thorpej  * Transmit descriptor list size.
     58   1.1  thorpej  */
     59   1.1  thorpej #define	SONIC_NTXDESC		32
     60   1.1  thorpej #define	SONIC_NTXDESC_MASK	(SONIC_NTXDESC - 1)
     61   1.1  thorpej #define	SONIC_NEXTTX(x)		(((x) + 1) & SONIC_NTXDESC_MASK)
     62   1.1  thorpej 
     63   1.1  thorpej /*
     64   1.1  thorpej  * Receive descriptor list size.
     65   1.1  thorpej  */
     66   1.1  thorpej #define	SONIC_NRXDESC		32
     67   1.1  thorpej #define	SONIC_NRXDESC_MASK	(SONIC_NRXDESC - 1)
     68   1.1  thorpej #define	SONIC_NEXTRX(x)		(((x) + 1) & SONIC_NRXDESC_MASK)
     69   1.1  thorpej #define	SONIC_PREVRX(x)		(((x) - 1) & SONIC_NRXDESC_MASK)
     70   1.1  thorpej #define	SONIC_RXSEQ_TO_DESC(x)	((x) & SONIC_NRXDESC_MASK)
     71   1.1  thorpej 
     72   1.1  thorpej /*
     73   1.9  tsutsui  * Number of CAM entries.
     74   1.9  tsutsui  */
     75   1.9  tsutsui #define	SONIC_NCAMENT		16
     76   1.9  tsutsui 
     77   1.9  tsutsui /*
     78   1.1  thorpej  * Control structures are DMA'd to the SONIC chip.  We allocate them in
     79   1.1  thorpej  * a single clump that maps to a single DMA segment to make several things
     80   1.1  thorpej  * easier.
     81   1.1  thorpej  */
     82   1.1  thorpej struct sonic_control_data16 {
     83   1.1  thorpej 	/*
     84   1.1  thorpej 	 * The transmit descriptors.
     85   1.1  thorpej 	 */
     86   1.1  thorpej 	struct sonic_tda16 scd_txdescs[SONIC_NTXDESC];
     87   1.1  thorpej 
     88   1.1  thorpej 	/*
     89   1.1  thorpej 	 * The receive descriptors.
     90   1.1  thorpej 	 */
     91   1.1  thorpej 	struct sonic_rda16 scd_rxdescs[SONIC_NRXDESC];
     92   1.1  thorpej 
     93   1.1  thorpej 	/*
     94   1.1  thorpej 	 * The receive resource descriptors.
     95   1.1  thorpej 	 */
     96   1.1  thorpej 	struct sonic_rra16 scd_rxbufs[SONIC_NRXDESC];
     97   1.1  thorpej 
     98   1.1  thorpej 	/*
     99   1.1  thorpej 	 * The CAM descriptors.
    100   1.1  thorpej 	 */
    101   1.9  tsutsui 	struct sonic_cda16 scd_cam[SONIC_NCAMENT];
    102   1.9  tsutsui 	uint16_t scd_camenable;
    103   1.1  thorpej };
    104   1.1  thorpej 
    105   1.1  thorpej #define	SONIC_CDOFF16(x)	offsetof(struct sonic_control_data16, x)
    106   1.1  thorpej #define	SONIC_CDTXOFF16(x)	SONIC_CDOFF16(scd_txdescs[(x)])
    107   1.1  thorpej #define	SONIC_CDRXOFF16(x)	SONIC_CDOFF16(scd_rxdescs[(x)])
    108   1.1  thorpej #define	SONIC_CDRROFF16(x)	SONIC_CDOFF16(scd_rxbufs[(x)])
    109   1.1  thorpej #define	SONIC_CDCAMOFF16	SONIC_CDOFF16(scd_cam)
    110   1.9  tsutsui #define	SONIC_CDCAMSIZE16	\
    111   1.9  tsutsui 	(sizeof(struct sonic_cda16) * SONIC_NCAMENT + sizeof(uint16_t))
    112   1.1  thorpej 
    113   1.1  thorpej struct sonic_control_data32 {
    114   1.1  thorpej 	/*
    115   1.1  thorpej 	 * The transmit descriptors.
    116   1.1  thorpej 	 */
    117   1.1  thorpej 	struct sonic_tda32 scd_txdescs[SONIC_NTXDESC];
    118   1.1  thorpej 
    119   1.1  thorpej 	/*
    120   1.1  thorpej 	 * The receive descriptors.
    121   1.1  thorpej 	 */
    122   1.1  thorpej 	struct sonic_rda32 scd_rxdescs[SONIC_NRXDESC];
    123   1.1  thorpej 
    124   1.1  thorpej 	/*
    125   1.1  thorpej 	 * The receive resource descriptors.
    126   1.1  thorpej 	 */
    127   1.1  thorpej 	struct sonic_rra32 scd_rxbufs[SONIC_NRXDESC];
    128   1.1  thorpej 
    129   1.1  thorpej 	/*
    130   1.1  thorpej 	 * The CAM descriptors.
    131   1.1  thorpej 	 */
    132   1.9  tsutsui 	struct sonic_cda32 scd_cam[SONIC_NCAMENT];
    133   1.9  tsutsui 	uint32_t scd_camenable;
    134   1.1  thorpej };
    135   1.1  thorpej 
    136   1.1  thorpej #define	SONIC_CDOFF32(x)	offsetof(struct sonic_control_data32, x)
    137   1.1  thorpej #define	SONIC_CDTXOFF32(x)	SONIC_CDOFF32(scd_txdescs[(x)])
    138   1.1  thorpej #define	SONIC_CDRXOFF32(x)	SONIC_CDOFF32(scd_rxdescs[(x)])
    139   1.1  thorpej #define	SONIC_CDRROFF32(x)	SONIC_CDOFF32(scd_rxbufs[(x)])
    140   1.1  thorpej #define	SONIC_CDCAMOFF32	SONIC_CDOFF32(scd_cam)
    141   1.9  tsutsui #define	SONIC_CDCAMSIZE32	\
    142   1.9  tsutsui 	(sizeof(struct sonic_cda32) * SONIC_NCAMENT + sizeof(uint32_t))
    143   1.1  thorpej 
    144   1.1  thorpej /*
    145   1.1  thorpej  * Software state for transmit and receive descriptors.
    146   1.1  thorpej  */
    147   1.1  thorpej struct sonic_descsoft {
    148   1.1  thorpej 	struct mbuf *ds_mbuf;		/* head of mbuf chain */
    149   1.1  thorpej 	bus_dmamap_t ds_dmamap;		/* our DMA map */
    150   1.1  thorpej };
    151   1.1  thorpej 
    152   1.1  thorpej /*
    153   1.1  thorpej  * Software state per device.
    154   1.1  thorpej  */
    155   1.1  thorpej struct sonic_softc {
    156  1.10  tsutsui 	device_t sc_dev;		/* generic device information */
    157   1.1  thorpej 	bus_space_tag_t sc_st;		/* bus space tag */
    158   1.1  thorpej 	bus_space_handle_t sc_sh;	/* bus space handle */
    159   1.1  thorpej 	bus_dma_tag_t sc_dmat;		/* bus DMA tag */
    160   1.1  thorpej 	struct ethercom sc_ethercom;	/* ethernet common data */
    161   1.1  thorpej 	void *sc_sdhook;		/* shutdown hook */
    162   1.1  thorpej 
    163   1.1  thorpej 	int sc_32bit;			/* use 32-bit mode */
    164   1.1  thorpej 	int sc_bigendian;		/* BMODE -> Vcc */
    165   1.1  thorpej 
    166   1.1  thorpej 	/* Our register map. */
    167   1.1  thorpej 	bus_addr_t sc_regmap[SONIC_NREGS];
    168   1.1  thorpej 
    169   1.1  thorpej 	bus_dmamap_t sc_cddmamap;	/* control data DMA map */
    170   1.1  thorpej #define	sc_cddma	sc_cddmamap->dm_segs[0].ds_addr
    171   1.4   bouyer 	bus_dmamap_t sc_nulldmamap;	/* DMA map for the pad buffer */
    172   1.4   bouyer #define sc_nulldma     sc_nulldmamap->dm_segs[0].ds_addr
    173   1.1  thorpej 
    174   1.1  thorpej 	/*
    175   1.1  thorpej 	 * Software state for transmit and receive descriptors.
    176   1.1  thorpej 	 */
    177   1.1  thorpej 	struct sonic_descsoft sc_txsoft[SONIC_NTXDESC];
    178   1.1  thorpej 	struct sonic_descsoft sc_rxsoft[SONIC_NRXDESC];
    179   1.1  thorpej 
    180   1.1  thorpej 	/*
    181   1.1  thorpej 	 * Control data structures.
    182   1.1  thorpej 	 */
    183   1.1  thorpej 	union {
    184   1.1  thorpej 		struct sonic_control_data16 *cdun_16;
    185   1.1  thorpej 		struct sonic_control_data32 *cdun_32;
    186   1.1  thorpej 	} sc_cdun;
    187   1.1  thorpej #define	sc_cdata16	sc_cdun.cdun_16
    188   1.1  thorpej #define	sc_cdata32	sc_cdun.cdun_32
    189   1.1  thorpej 
    190   1.1  thorpej #define	sc_tda16	sc_cdun.cdun_16->scd_txdescs
    191   1.1  thorpej #define	sc_rda16	sc_cdun.cdun_16->scd_rxdescs
    192   1.1  thorpej #define	sc_rra16	sc_cdun.cdun_16->scd_rxbufs
    193   1.1  thorpej #define	sc_cda16	sc_cdun.cdun_16->scd_cam
    194   1.9  tsutsui #define	sc_cdaenable16	sc_cdun.cdun_16->scd_camenable
    195   1.1  thorpej 
    196   1.1  thorpej #define	sc_tda32	sc_cdun.cdun_32->scd_txdescs
    197   1.1  thorpej #define	sc_rda32	sc_cdun.cdun_32->scd_rxdescs
    198   1.1  thorpej #define	sc_rra32	sc_cdun.cdun_32->scd_rxbufs
    199   1.1  thorpej #define	sc_cda32	sc_cdun.cdun_32->scd_cam
    200   1.9  tsutsui #define	sc_cdaenable32	sc_cdun.cdun_32->scd_camenable
    201   1.1  thorpej 
    202   1.1  thorpej 	int	sc_txpending;		/* number of Tx requests pending */
    203   1.1  thorpej 	int	sc_txdirty;		/* first dirty Tx descriptor */
    204   1.1  thorpej 	int	sc_txlast;		/* last used Tx descriptor */
    205   1.1  thorpej 
    206   1.1  thorpej 	int	sc_rxptr;		/* next ready Rx descriptor */
    207   1.1  thorpej 
    208   1.1  thorpej 	uint16_t sc_imr;		/* prototype IMR */
    209   1.1  thorpej 	uint16_t sc_dcr;		/* prototype DCR */
    210   1.1  thorpej 	uint16_t sc_dcr2;		/* prototype DCR2 */
    211   1.1  thorpej };
    212   1.1  thorpej 
    213   1.1  thorpej #define	CSR_READ(sc, reg)						\
    214   1.1  thorpej 	bus_space_read_2((sc)->sc_st, (sc)->sc_sh,			\
    215   1.1  thorpej 	    (sc)->sc_regmap[(reg)])
    216   1.1  thorpej 
    217   1.1  thorpej #define	CSR_WRITE(sc, reg, val)						\
    218   1.1  thorpej 	bus_space_write_2((sc)->sc_st, (sc)->sc_sh,			\
    219   1.1  thorpej 	    (sc)->sc_regmap[(reg)], (val))
    220   1.1  thorpej 
    221   1.2  thorpej #define	SONIC_CDTXADDR16(sc, x)						\
    222   1.2  thorpej 	((sc)->sc_cddma + SONIC_CDTXOFF16((x)))
    223   1.2  thorpej 
    224   1.2  thorpej #define	SONIC_CDTXADDR32(sc, x)						\
    225   1.2  thorpej 	((sc)->sc_cddma + SONIC_CDTXOFF32((x)))
    226   1.2  thorpej 
    227   1.1  thorpej #define	SONIC_CDTXADDR(sc, x)						\
    228   1.2  thorpej 	((sc)->sc_32bit ? SONIC_CDTXADDR32((sc), (x)) :			\
    229   1.2  thorpej 	    SONIC_CDTXADDR16((sc), (x)))
    230   1.2  thorpej 
    231   1.2  thorpej #define	SONIC_CDRXADDR16(sc, x)						\
    232   1.2  thorpej 	((sc)->sc_cddma + SONIC_CDRXOFF16((x)))
    233   1.2  thorpej 
    234   1.2  thorpej #define	SONIC_CDRXADDR32(sc, x)						\
    235   1.2  thorpej 	((sc)->sc_cddma + SONIC_CDRXOFF32((x)))
    236   1.1  thorpej 
    237   1.1  thorpej #define	SONIC_CDRXADDR(sc, x)						\
    238   1.2  thorpej 	((sc)->sc_32bit ? SONIC_CDRXADDR32((sc), (x)) :			\
    239   1.2  thorpej 	    SONIC_CDRXADDR16((sc), (x)))
    240   1.1  thorpej 
    241   1.1  thorpej #define	SONIC_CDRRADDR(sc, x)						\
    242   1.1  thorpej 	((sc)->sc_cddma +						\
    243   1.1  thorpej 	 ((sc)->sc_32bit ? SONIC_CDRROFF32((x)) : SONIC_CDRROFF16((x))))
    244   1.1  thorpej 
    245   1.1  thorpej #define	SONIC_CDCAMADDR(sc)						\
    246   1.1  thorpej 	((sc)->sc_cddma +						\
    247   1.8  tsutsui 	 ((sc)->sc_32bit ? SONIC_CDCAMOFF32 : SONIC_CDCAMOFF16))
    248   1.1  thorpej 
    249   1.2  thorpej #define	SONIC_CDTXSYNC16(sc, x, ops)					\
    250   1.2  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    251   1.2  thorpej 	    SONIC_CDTXOFF16((x)), sizeof(struct sonic_tda16), (ops))
    252   1.2  thorpej 
    253   1.2  thorpej #define	SONIC_CDTXSYNC32(sc, x, ops)					\
    254   1.2  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    255   1.2  thorpej 	    SONIC_CDTXOFF32((x)), sizeof(struct sonic_tda32), (ops))
    256   1.2  thorpej 
    257   1.2  thorpej #define	SONIC_CDRXSYNC16(sc, x, ops)					\
    258   1.2  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    259   1.2  thorpej 	    SONIC_CDRXOFF16((x)), sizeof(struct sonic_rda16), (ops))
    260   1.2  thorpej 
    261   1.2  thorpej #define	SONIC_CDRXSYNC32(sc, x, ops)					\
    262   1.2  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    263   1.2  thorpej 	    SONIC_CDRXOFF32((x)), sizeof(struct sonic_rda32), (ops))
    264   1.2  thorpej 
    265   1.2  thorpej #define	SONIC_CDRRSYNC16(sc, x, ops)					\
    266   1.2  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    267   1.2  thorpej 	    SONIC_CDRROFF16((x)), sizeof(struct sonic_rra16), (ops))
    268   1.2  thorpej 
    269   1.2  thorpej #define	SONIC_CDRRSYNC32(sc, x, ops)					\
    270   1.2  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    271   1.2  thorpej 	    SONIC_CDRROFF32((x)), sizeof(struct sonic_rra32), (ops))
    272   1.1  thorpej 
    273   1.1  thorpej #define	SONIC_CDCAMSYNC(sc, ops)					\
    274   1.1  thorpej do {									\
    275   1.1  thorpej 	if ((sc)->sc_32bit)						\
    276   1.1  thorpej 		bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,	\
    277   1.9  tsutsui 		    SONIC_CDCAMOFF32, SONIC_CDCAMSIZE32,		\
    278   1.1  thorpej 		    (ops));						\
    279   1.1  thorpej 	else								\
    280   1.1  thorpej 		bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,	\
    281   1.9  tsutsui 		    SONIC_CDCAMOFF16, SONIC_CDCAMSIZE16,		\
    282   1.1  thorpej 		    (ops));						\
    283   1.1  thorpej } while (/*CONSTCOND*/0)
    284   1.1  thorpej 
    285   1.1  thorpej #define	SONIC_INIT_RXDESC(sc, x)					\
    286   1.1  thorpej do {									\
    287   1.1  thorpej 	struct sonic_descsoft *__ds = &(sc)->sc_rxsoft[(x)];		\
    288   1.1  thorpej 	struct mbuf *__m = __ds->ds_mbuf;				\
    289   1.1  thorpej 									\
    290   1.1  thorpej 	if ((sc)->sc_32bit) {						\
    291   1.1  thorpej 		/*							\
    292   1.1  thorpej 		 * Unfortuantely, in 32-bit mode, the Rx buffer must	\
    293   1.1  thorpej 		 * be 32-bit aligned.					\
    294   1.1  thorpej 		 */							\
    295   1.1  thorpej 		struct sonic_rda32 *__rda = &(sc)->sc_rda32[(x)];	\
    296   1.1  thorpej 		struct sonic_rda32 *__prda =				\
    297   1.1  thorpej 		    &(sc)->sc_rda32[SONIC_PREVRX((x))];			\
    298   1.1  thorpej 		struct sonic_rra32 *__rra = &(sc)->sc_rra32[(x)];	\
    299   1.1  thorpej 									\
    300   1.1  thorpej 		__m->m_data = __m->m_ext.ext_buf;			\
    301   1.1  thorpej 									\
    302   1.1  thorpej 		__rra->rra_ptr1 =					\
    303   1.1  thorpej 		    __ds->ds_dmamap->dm_segs[0].ds_addr >> 16;		\
    304   1.1  thorpej 		__rra->rra_ptr0 =					\
    305   1.1  thorpej 		    __ds->ds_dmamap->dm_segs[0].ds_addr & 0xffff;	\
    306   1.1  thorpej 		__rra->rra_wc1 = 0;					\
    307   1.1  thorpej 		__rra->rra_wc0 = (ETHER_MAX_LEN + 6) / 2;		\
    308   1.1  thorpej 									\
    309   1.1  thorpej 		__rda->rda_link =					\
    310   1.2  thorpej 		    (SONIC_CDRXADDR32((sc), SONIC_NEXTRX((x))) & 0xffff) |\
    311   1.1  thorpej 		    RDA_LINK_EOL;					\
    312   1.1  thorpej 		__rda->rda_inuse = 1;					\
    313   1.1  thorpej 									\
    314   1.2  thorpej 		__prda->rda_link = SONIC_CDRXADDR32((sc), (x));		\
    315   1.2  thorpej 									\
    316   1.2  thorpej 		SONIC_CDRRSYNC32((sc), (x), BUS_DMASYNC_PREWRITE);	\
    317   1.2  thorpej 		SONIC_CDRXSYNC32((sc), (x),				\
    318   1.2  thorpej 		    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);		\
    319   1.2  thorpej 		SONIC_CDRXSYNC32((sc), SONIC_PREVRX(x),			\
    320   1.2  thorpej 		    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);		\
    321   1.1  thorpej 	} else {							\
    322   1.1  thorpej 		/*							\
    323   1.1  thorpej 		 * In 16-bit mode, we scoot the packet forward 2 bytes	\
    324   1.1  thorpej 		 * so that the payload after the Ethernet header is	\
    325   1.1  thorpej 		 * suitably aligned.					\
    326   1.1  thorpej 		 */							\
    327   1.1  thorpej 		struct sonic_rda16 *__rda = &(sc)->sc_rda16[(x)];	\
    328   1.1  thorpej 		struct sonic_rda16 *__prda =				\
    329   1.1  thorpej 		    &(sc)->sc_rda16[SONIC_PREVRX((x))];			\
    330   1.1  thorpej 		struct sonic_rra16 *__rra = &(sc)->sc_rra16[(x)];	\
    331   1.1  thorpej 									\
    332   1.1  thorpej 		__m->m_data = __m->m_ext.ext_buf + 2;			\
    333   1.1  thorpej 									\
    334   1.1  thorpej 		__rra->rra_ptr1 =					\
    335   1.1  thorpej 		    __ds->ds_dmamap->dm_segs[0].ds_addr >> 16;		\
    336   1.1  thorpej 		__rra->rra_ptr0 =					\
    337   1.1  thorpej 		    (__ds->ds_dmamap->dm_segs[0].ds_addr + 2) & 0xffff;	\
    338   1.1  thorpej 		__rra->rra_wc1 = 0;					\
    339   1.1  thorpej 		__rra->rra_wc0 = (ETHER_MAX_LEN + 2) / 2;		\
    340   1.1  thorpej 									\
    341   1.1  thorpej 		__rda->rda_link =					\
    342   1.2  thorpej 		    (SONIC_CDRXADDR16((sc), SONIC_NEXTRX((x))) & 0xffff) |\
    343   1.1  thorpej 		    RDA_LINK_EOL;					\
    344   1.1  thorpej 		__rda->rda_inuse = 1;					\
    345   1.1  thorpej 									\
    346   1.2  thorpej 		__prda->rda_link = SONIC_CDRXADDR16((sc), (x));		\
    347   1.2  thorpej 									\
    348   1.2  thorpej 		SONIC_CDRRSYNC16((sc), (x), BUS_DMASYNC_PREWRITE);	\
    349   1.2  thorpej 		SONIC_CDRXSYNC16((sc), (x),				\
    350   1.2  thorpej 		    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);		\
    351   1.2  thorpej 		SONIC_CDRXSYNC16((sc), SONIC_PREVRX(x),			\
    352   1.2  thorpej 		    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);		\
    353   1.1  thorpej 	}								\
    354   1.1  thorpej } while (/*CONSTCOND*/0)
    355   1.1  thorpej 
    356   1.7    perry static __inline uint16_t __unused
    357   1.1  thorpej htosonic16(struct sonic_softc *sc, uint16_t val)
    358   1.1  thorpej {
    359   1.1  thorpej 
    360   1.1  thorpej 	if (sc->sc_bigendian)
    361   1.1  thorpej 		return (htobe16(val));
    362   1.1  thorpej 	return (htole16(val));
    363   1.1  thorpej }
    364   1.1  thorpej 
    365   1.7    perry static __inline uint16_t __unused
    366   1.1  thorpej sonic16toh(struct sonic_softc *sc, uint16_t val)
    367   1.1  thorpej {
    368   1.1  thorpej 
    369   1.1  thorpej 	if (sc->sc_bigendian)
    370   1.1  thorpej 		return (be16toh(val));
    371   1.1  thorpej 	return (le16toh(val));
    372   1.1  thorpej }
    373   1.1  thorpej 
    374   1.7    perry static __inline uint32_t __unused
    375   1.1  thorpej htosonic32(struct sonic_softc *sc, uint32_t val)
    376   1.1  thorpej {
    377   1.1  thorpej 
    378   1.1  thorpej 	if (sc->sc_bigendian)
    379   1.1  thorpej 		return (htobe32(val));
    380   1.3  thorpej 	return (htole32(val));
    381   1.1  thorpej }
    382   1.1  thorpej 
    383   1.7    perry static __inline uint32_t __unused
    384   1.1  thorpej sonic32toh(struct sonic_softc *sc, uint32_t val)
    385   1.1  thorpej {
    386   1.1  thorpej 
    387   1.1  thorpej 	if (sc->sc_bigendian)
    388   1.1  thorpej 		return (be32toh(val));
    389   1.1  thorpej 	return (le32toh(val));
    390   1.1  thorpej }
    391   1.1  thorpej 
    392   1.1  thorpej #ifdef _KERNEL
    393   1.1  thorpej void	sonic_attach(struct sonic_softc *, const uint8_t *);
    394   1.1  thorpej int	sonic_intr(void *);
    395   1.1  thorpej #endif /* _KERNEL */
    396   1.1  thorpej 
    397   1.1  thorpej #endif /* _DEV_IC_DP83932VAR_H_ */
    398