]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/dev/usb/net/if_cdcereg.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / dev / usb / net / if_cdcereg.h
1 /*-
2  * Copyright (c) 2003-2005 Craig Boston
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by Bill Paul.
16  * 4. Neither the name of the author nor the names of any co-contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul, THE VOICES IN HIS HEAD OR
24  * THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * $FreeBSD$
33  */
34
35 #ifndef _USB_IF_CDCEREG_H_
36 #define _USB_IF_CDCEREG_H_
37
38 #define CDCE_FRAMES_MAX 8               /* units */
39 #define CDCE_IND_SIZE_MAX 32            /* bytes */
40
41 #define CDCE_NCM_TX_MAXLEN 2048UL       /* bytes */
42 #define CDCE_NCM_TX_FRAMES_MAX 8        /* units */
43
44 #define CDCE_NCM_RX_MAXLEN (1UL << 14)  /* bytes */
45 #define CDCE_NCM_RX_FRAMES_MAX 1        /* units */
46
47 #define CDCE_NCM_SUBFRAMES_MAX 32       /* units */
48
49 #ifndef CDCE_HAVE_NCM
50 #define CDCE_HAVE_NCM 1
51 #endif
52
53 enum {
54         CDCE_BULK_RX,
55         CDCE_BULK_TX,
56         CDCE_INTR_RX,
57         CDCE_INTR_TX,
58         CDCE_N_TRANSFER,
59 };
60
61 struct cdce_ncm {
62         struct usb_ncm16_hdr hdr;
63         struct usb_ncm16_dpt dpt;
64         struct usb_ncm16_dp dp[CDCE_NCM_SUBFRAMES_MAX];
65         uint32_t rx_max;
66         uint32_t tx_max;
67         uint16_t tx_remainder;
68         uint16_t tx_modulus;
69         uint16_t tx_struct_align;
70         uint16_t tx_seq;
71 };
72
73 struct cdce_softc {
74         struct usb_ether        sc_ue;
75         struct mtx              sc_mtx;
76 #if CDCE_HAVE_NCM
77         struct cdce_ncm         sc_ncm;
78 #endif
79         struct usb_xfer *sc_xfer[CDCE_N_TRANSFER];
80         struct mbuf             *sc_rx_buf[CDCE_FRAMES_MAX];
81         struct mbuf             *sc_tx_buf[CDCE_FRAMES_MAX];
82
83         int                     sc_flags;
84 #define CDCE_FLAG_ZAURUS        0x0001
85 #define CDCE_FLAG_NO_UNION      0x0002
86 #define CDCE_FLAG_RX_DATA       0x0010
87
88         uint8_t sc_eaddr_str_index;
89         uint8_t sc_ifaces_index[2];
90 };
91
92 #define CDCE_LOCK(_sc)                  mtx_lock(&(_sc)->sc_mtx)
93 #define CDCE_UNLOCK(_sc)                mtx_unlock(&(_sc)->sc_mtx)
94 #define CDCE_LOCK_ASSERT(_sc, t)        mtx_assert(&(_sc)->sc_mtx, t)
95 #endif                                  /* _USB_IF_CDCEREG_H_ */