2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 2003-2005 Craig Boston
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Bill Paul.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul, THE VOICES IN HIS HEAD OR
26 * THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #ifndef _USB_IF_CDCEREG_H_
38 #define _USB_IF_CDCEREG_H_
40 #define CDCE_FRAMES_MAX 8 /* units */
41 #define CDCE_IND_SIZE_MAX 32 /* bytes */
43 #define CDCE_NCM_TX_MINLEN 512 /* bytes, must be power of two */
44 #define CDCE_NCM_TX_MAXLEN (16384 + 4) /* bytes, must be short terminated */
45 #define CDCE_NCM_TX_FRAMES_MAX 8 /* units */
47 #define CDCE_NCM_RX_MAXLEN (1UL << 14) /* bytes */
48 #define CDCE_NCM_RX_FRAMES_MAX 1 /* units */
50 #define CDCE_NCM_SUBFRAMES_MAX 32 /* units */
52 #define CDCE_NCM_ALIGN(rem,off,mod) \
53 ((uint32_t)(((uint32_t)(rem)) - \
54 ((uint32_t)((-(uint32_t)(off)) & (-(uint32_t)(mod))))))
57 #define CDCE_HAVE_NCM 1
69 struct usb_ncm16_hdr hdr;
70 struct usb_ncm16_dpt dpt;
71 struct usb_ncm16_dp dp[CDCE_NCM_SUBFRAMES_MAX];
74 uint16_t tx_remainder;
76 uint16_t tx_struct_align;
82 struct usb_ether sc_ue;
85 struct cdce_ncm sc_ncm;
87 struct usb_xfer *sc_xfer[CDCE_N_TRANSFER];
88 struct mbuf *sc_rx_buf[CDCE_FRAMES_MAX];
89 struct mbuf *sc_tx_buf[CDCE_FRAMES_MAX];
92 #define CDCE_FLAG_ZAURUS 0x0001
93 #define CDCE_FLAG_NO_UNION 0x0002
94 #define CDCE_FLAG_RX_DATA 0x0010
96 uint8_t sc_eaddr_str_index;
97 uint8_t sc_ifaces_index[2];
98 uint8_t sc_notify_state;
99 #define CDCE_NOTIFY_NETWORK_CONNECTION 0
100 #define CDCE_NOTIFY_SPEED_CHANGE 1
101 #define CDCE_NOTIFY_DONE 2
104 #define CDCE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
105 #define CDCE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
106 #define CDCE_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t)
107 #endif /* _USB_IF_CDCEREG_H_ */