[BACK]Return to if_skvar.h CVS log [TXT][DIR] Up to [local] / sys / dev / pci

Annotation of sys/dev/pci/if_skvar.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: if_skvar.h,v 1.2 2005/12/22 20:54:47 brad Exp $       */
                      2: /*     $NetBSD: if_skvar.h,v 1.6 2005/05/30 04:35:22 christos Exp $    */
                      3:
                      4: /*-
                      5:  * Copyright (c) 2003 The NetBSD Foundation, Inc.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by the NetBSD
                     19:  *     Foundation, Inc. and its contributors.
                     20:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     21:  *    contributors may be used to endorse or promote products derived
                     22:  *    from this software without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     25:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     26:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     27:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     28:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     29:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     30:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     31:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     32:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     33:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     34:  * POSSIBILITY OF SUCH DAMAGE.
                     35:  */
                     36: /*     $OpenBSD: if_skvar.h,v 1.2 2005/12/22 20:54:47 brad Exp $       */
                     37:
                     38: /*
                     39:  * Copyright (c) 1997, 1998, 1999, 2000
                     40:  *     Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
                     41:  *
                     42:  * Redistribution and use in source and binary forms, with or without
                     43:  * modification, are permitted provided that the following conditions
                     44:  * are met:
                     45:  * 1. Redistributions of source code must retain the above copyright
                     46:  *    notice, this list of conditions and the following disclaimer.
                     47:  * 2. Redistributions in binary form must reproduce the above copyright
                     48:  *    notice, this list of conditions and the following disclaimer in the
                     49:  *    documentation and/or other materials provided with the distribution.
                     50:  * 3. All advertising materials mentioning features or use of this software
                     51:  *    must display the following acknowledgement:
                     52:  *     This product includes software developed by Bill Paul.
                     53:  * 4. Neither the name of the author nor the names of any co-contributors
                     54:  *    may be used to endorse or promote products derived from this software
                     55:  *    without specific prior written permission.
                     56:  *
                     57:  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
                     58:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     59:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     60:  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
                     61:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     62:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     63:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     64:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     65:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     66:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
                     67:  * THE POSSIBILITY OF SUCH DAMAGE.
                     68:  *
                     69:  * $FreeBSD: /c/ncvs/src/sys/pci/if_skreg.h,v 1.9 2000/04/22 02:16:37 wpaul Exp $
                     70:  */
                     71:
                     72: /*
                     73:  * Copyright (c) 2003 Nathan L. Binkert <binkertn@umich.edu>
                     74:  *
                     75:  * Permission to use, copy, modify, and distribute this software for any
                     76:  * purpose with or without fee is hereby granted, provided that the above
                     77:  * copyright notice and this permission notice appear in all copies.
                     78:  *
                     79:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     80:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     81:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     82:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     83:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     84:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     85:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     86:  */
                     87:
                     88: #ifndef _DEV_PCI_IF_SKVAR_H_
                     89: #define _DEV_PCI_IF_SKVAR_H_
                     90:
                     91: struct sk_jpool_entry {
                     92:        int                             slot;
                     93:        LIST_ENTRY(sk_jpool_entry)      jpool_entries;
                     94: };
                     95:
                     96: struct sk_chain {
                     97:        void                    *sk_desc;
                     98:        struct mbuf             *sk_mbuf;
                     99:        struct sk_chain         *sk_next;
                    100: };
                    101:
                    102: /*
                    103:  * Number of DMA segments in a TxCB. Note that this is carefully
                    104:  * chosen to make the total struct size an even power of two. It's
                    105:  * critical that no TxCB be split across a page boundary since
                    106:  * no attempt is made to allocate physically contiguous memory.
                    107:  *
                    108:  */
                    109: #define SK_NTXSEG      30
                    110:
                    111: struct sk_txmap_entry {
                    112:        bus_dmamap_t                    dmamap;
                    113:        SIMPLEQ_ENTRY(sk_txmap_entry)   link;
                    114: };
                    115:
                    116: struct sk_chain_data {
                    117:        struct sk_chain         sk_tx_chain[SK_TX_RING_CNT];
                    118:        struct sk_chain         sk_rx_chain[SK_RX_RING_CNT];
                    119:        struct sk_txmap_entry   *sk_tx_map[SK_TX_RING_CNT];
                    120:        bus_dmamap_t            sk_rx_map[SK_RX_RING_CNT];
                    121:        bus_dmamap_t            sk_rx_jumbo_map;
                    122:        int                     sk_tx_prod;
                    123:        int                     sk_tx_cons;
                    124:        int                     sk_tx_cnt;
                    125:        int                     sk_rx_prod;
                    126:        int                     sk_rx_cons;
                    127:        int                     sk_rx_cnt;
                    128:        /* Stick the jumbo mem management stuff here too. */
                    129:        caddr_t                 sk_jslots[SK_JSLOTS];
                    130:        void                    *sk_jumbo_buf;
                    131:
                    132: };
                    133:
                    134: struct sk_ring_data {
                    135:        struct sk_tx_desc       sk_tx_ring[SK_TX_RING_CNT];
                    136:        struct sk_rx_desc       sk_rx_ring[SK_RX_RING_CNT];
                    137: };
                    138:
                    139: #define SK_TX_RING_ADDR(sc, i) \
                    140:     ((sc)->sk_ring_map->dm_segs[0].ds_addr + \
                    141:      offsetof(struct sk_ring_data, sk_tx_ring[(i)]))
                    142:
                    143: #define SK_RX_RING_ADDR(sc, i) \
                    144:     ((sc)->sk_ring_map->dm_segs[0].ds_addr + \
                    145:      offsetof(struct sk_ring_data, sk_rx_ring[(i)]))
                    146:
                    147: #define SK_CDOFF(x)    offsetof(struct sk_ring_data, x)
                    148: #define SK_CDTXOFF(x)  SK_CDOFF(sk_tx_ring[(x)])
                    149: #define SK_CDRXOFF(x)  SK_CDOFF(sk_rx_ring[(x)])
                    150:
                    151: #define SK_CDTXSYNC(sc, x, n, ops)                                     \
                    152: do {                                                                   \
                    153:        int __x, __n;                                                   \
                    154:                                                                        \
                    155:        __x = (x);                                                      \
                    156:        __n = (n);                                                      \
                    157:                                                                        \
                    158:        /* If it will wrap around, sync to the end of the ring. */      \
                    159:        if ((__x + __n) > SK_TX_RING_CNT) {                             \
                    160:                bus_dmamap_sync((sc)->sk_softc->sc_dmatag,              \
                    161:                    (sc)->sk_ring_map, SK_CDTXOFF(__x),                 \
                    162:                    sizeof(struct sk_tx_desc) *  (SK_TX_RING_CNT - __x),\
                    163:                    (ops));                                             \
                    164:                __n -= (SK_TX_RING_CNT - __x);                          \
                    165:                __x = 0;                                                \
                    166:        }                                                               \
                    167:                                                                        \
                    168:        /* Now sync whatever is left. */                                \
                    169:        bus_dmamap_sync((sc)->sk_softc->sc_dmatag, (sc)->sk_ring_map,   \
                    170:            SK_CDTXOFF((__x)), sizeof(struct sk_tx_desc) * __n, (ops)); \
                    171: } while (/*CONSTCOND*/0)
                    172:
                    173: #define SK_CDRXSYNC(sc, x, ops)                                                \
                    174: do {                                                                   \
                    175:        bus_dmamap_sync((sc)->sk_softc->sc_dmatag, (sc)->sk_ring_map,   \
                    176:            SK_CDRXOFF((x)), sizeof(struct sk_rx_desc), (ops));         \
                    177: } while (/*CONSTCOND*/0)
                    178:
                    179: struct sk_bcom_hack {
                    180:        int                     reg;
                    181:        int                     val;
                    182: };
                    183:
                    184: #define SK_INC(x, y)   (x) = (x + 1) % y
                    185:
                    186: /* Forward decl. */
                    187: struct sk_if_softc;
                    188:
                    189: /* Softc for the GEnesis controller. */
                    190: struct sk_softc {
                    191:        struct device           sk_dev;         /* generic device */
                    192:        bus_space_handle_t      sk_bhandle;     /* bus space handle */
                    193:        bus_space_tag_t         sk_btag;        /* bus space tag */
                    194:        void                    *sk_intrhand;   /* irq handler handle */
                    195:        u_int8_t                sk_coppertype;
                    196:        u_int8_t                sk_pmd;         /* physical media type */
                    197:        u_int8_t                sk_type;
                    198:        u_int8_t                sk_rev;
                    199:        u_int8_t                sk_macs;        /* # of MACs */
                    200:        char                    *sk_name;
                    201:        u_int32_t               sk_rboff;       /* RAMbuffer offset */
                    202:        u_int32_t               sk_ramsize;     /* amount of RAM on NIC */
                    203:        u_int32_t               sk_intrmask;
                    204:        bus_dma_tag_t           sc_dmatag;
                    205:        struct sk_if_softc      *sk_if[2];
                    206: };
                    207:
                    208: /* Softc for each logical interface */
                    209: struct sk_if_softc {
                    210:        struct device           sk_dev;         /* generic device */
                    211:        struct arpcom           arpcom;         /* interface info */
                    212:        struct mii_data         sk_mii;
                    213:        u_int8_t                sk_port;        /* port # on controller */
                    214:        u_int8_t                sk_xmac_rev;    /* XMAC chip rev (B2 or C1) */
                    215:        u_int32_t               sk_rx_ramstart;
                    216:        u_int32_t               sk_rx_ramend;
                    217:        u_int32_t               sk_tx_ramstart;
                    218:        u_int32_t               sk_tx_ramend;
                    219:        u_int8_t                sk_phytype;
                    220:        int                     sk_phyaddr;
                    221:        int                     sk_cnt;
                    222:        int                     sk_link;
                    223:        struct timeout          sk_tick_ch;
                    224:        struct sk_chain_data    sk_cdata;
                    225:        struct sk_ring_data     *sk_rdata;
                    226:        bus_dmamap_t            sk_ring_map;
                    227:        struct sk_softc         *sk_softc;      /* parent controller */
                    228:        int                     sk_tx_bmu;      /* TX BMU register */
                    229:        int                     sk_if_flags;
                    230:        LIST_HEAD(__sk_jfreehead, sk_jpool_entry)       sk_jfree_listhead;
                    231:        LIST_HEAD(__sk_jinusehead, sk_jpool_entry)      sk_jinuse_listhead;
                    232:        SIMPLEQ_HEAD(__sk_txmaphead, sk_txmap_entry)    sk_txmap_head;
                    233: };
                    234:
                    235: struct skc_attach_args {
                    236:        u_int16_t       skc_port;
                    237:        u_int8_t        skc_type;
                    238:        u_int8_t        skc_rev;
                    239: };
                    240:
                    241: #endif /* _DEV_PCI_IF_SKVAR_H_ */

CVSweb